package com.example.superoa.common;


import java.sql.Time;
import java.text.ParseException;
import java.text.SimpleDateFormat;

import org.springframework.core.convert.converter.Converter;

public class TimeConverter implements Converter<String,Time>{

	@Override
	public Time convert(String source) {
		SimpleDateFormat sdf = null;
		if("".equals(source) && source== null) {
			return null;
		}
		if(source.matches("\\d{1,2}:\\d{1,2}")) {
				sdf = new SimpleDateFormat("HH:mm");
		}else {
			return null;
		}
		try {
			return new Time(sdf.parse(source).getTime());
		} catch (ParseException e) {
			e.printStackTrace();
		}
		return null;
	}

}
